package com.timo.shopp.management.controller;

import com.alibaba.fastjson.JSONObject;
import com.timo.shopp.common.service.RedisServer;
import com.timo.shopp.common.util.Result;
import com.timo.shopp.management.service.RedisService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Timo
 * @Date: 2019/3/25 10:40
 * @Description: redis 控制器
 * 主要是用于测试redis数据的存取
 */
@RestController
@RequestMapping("/redis")
public class RedisController {

    @Resource
    private RedisService redisServer;

    @GetMapping("/get")
    public Result get(String key) {
        return Result.success(redisServer.get(key, JSONObject.class));
    }


    @GetMapping("/set")
    public Result set(String key, String value) {
        redisServer.set(key,value);
        return Result.success(200);
    }

}
